<html>
<head><meta charset="utf-8"><title>Making ParamEnv smaller makes rustc slower instead of faster · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html">Making ParamEnv smaller makes rustc slower instead of faster</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210891410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210891410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210891410">(Sep 22 2020 at 15:57)</a>:</h4>
<p>This is very strange. <a href="https://github.com/rust-lang/rust/issues/77058">https://github.com/rust-lang/rust/issues/77058</a></p>



<a name="210892298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892298">(Sep 22 2020 at 16:02)</a>:</h4>
<p>This is absolutely fantastic</p>



<a name="210892733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892733">(Sep 22 2020 at 16:05)</a>:</h4>
<p>I just thought about this and have a guess about why this is happening</p>



<a name="210892877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892877">(Sep 22 2020 at 16:06)</a>:</h4>
<p>removing the <code>Option&lt;DefId&gt;</code> means that <code>PredicateObligation</code> now only has a niche of size 1 (in <code>Predicate</code> instead of a niche of size 254 (edit: no 4 bytes + 254)</p>



<a name="210892921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892921">(Sep 22 2020 at 16:06)</a>:</h4>
<blockquote>
<p>This is very strange. </p>
<p>This is absolutely fantastic</p>
</blockquote>
<p>I enjoy the juxtaposition</p>



<a name="210892961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892961">(Sep 22 2020 at 16:07)</a>:</h4>
<p>I think 'fantastic' as in 'it seems like fantasy' ;)</p>



<a name="210892974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210892974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210892974">(Sep 22 2020 at 16:07)</a>:</h4>
<p>which might cause some enums using <code>PredicateObligation</code> to have worse codegen in patternmatching</p>



<a name="210893423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210893423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210893423">(Sep 22 2020 at 16:10)</a>:</h4>
<p>or there is a cutoff at 32 bytes which actually hurts performance</p>



<a name="210893464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210893464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210893464">(Sep 22 2020 at 16:10)</a>:</h4>
<p><code>Flavor::Fastcall</code> uses this to decide on if to use a register afaict</p>



<a name="210893793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210893793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210893793">(Sep 22 2020 at 16:12)</a>:</h4>
<p>maybe <code>pub enum ImplSource&lt;'tcx, N&gt; {</code></p>



<a name="210896559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210896559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210896559">(Sep 22 2020 at 16:32)</a>:</h4>
<blockquote>
<p>I just thought about this and have a guess about why this is happening</p>
</blockquote>
<p>I don't think my first guess was correct, so probably it's "or there is a cutoff at 32 bytes which actually hurts performance [in this case]"</p>



<a name="210955106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955106">(Sep 23 2020 at 03:02)</a>:</h4>
<p>Can you get profiling data to see where the cost goes?</p>



<a name="210955142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955142">(Sep 23 2020 at 03:03)</a>:</h4>
<p>Also, random question: does instruction count count <code>rep movs</code> or similar as one instruction or one per rep count?</p>



<a name="210955146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955146">(Sep 23 2020 at 03:03)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span></p>



<a name="210955196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955196">(Sep 23 2020 at 03:04)</a>:</h4>
<p>hilariously, one</p>



<a name="210955211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955211">(Sep 23 2020 at 03:04)</a>:</h4>
<p>(I was testing <code>iret</code>s from pagefaults and at some point I was using some primitive that was turning into that kind of memset)</p>



<a name="210955262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955262">(Sep 23 2020 at 03:05)</a>:</h4>
<p>to be fair, it is <em>the</em> <code>memset</code> instruction and it might as well send a special command to the DRAM to set entire rows to the bitpattern at ridiculous throughputs :P</p>



<a name="210955264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955264">(Sep 23 2020 at 03:06)</a>:</h4>
<p>(but I doubt it actually does that)</p>



<a name="210955316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955316">(Sep 23 2020 at 03:06)</a>:</h4>
<p>that should be a thing for zeroing, it'd be great</p>



<a name="210955343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210955343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210955343">(Sep 23 2020 at 03:07)</a>:</h4>
<p>anyway yeah it's a shame memory bandwidth is hard to measure, and for cache misses you have too many different counters to look at in terms of the cache hierarchy, but we should at least try (especially if we can get, like, 6 counters total or something, we only need 2 for counting instructions, the rest could be from the cache hierarchy)</p>



<a name="210958582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210958582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210958582">(Sep 23 2020 at 04:33)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I'm wondering if it's possible that, when the size shrinks below a certain threshold, code generation switches from <code>rep movs</code> to "move via fixed set of instructions/registers", which might make the instruction count go up but the time go down.</p>



<a name="210958593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/210958593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#210958593">(Sep 23 2020 at 04:33)</a>:</h4>
<p>Ah, but the issue says wall-clock goes up even more. Nevermind.</p>



<a name="211024567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/211024567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#211024567">(Sep 23 2020 at 16:03)</a>:</h4>
<p>Yeah, we were <em>okay</em> with the 2-3% increase in instruction counts for unicode_normalization, since several other tests had &gt;1% decrease in instruction counts. But we didn't notice the 25% increase in wall time <span aria-label="cold sweat" class="emoji emoji-1f630" role="img" title="cold sweat">:cold_sweat:</span></p>



<a name="211078105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/211078105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#211078105">(Sep 24 2020 at 00:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster/near/210955264">said</a>:</p>
<blockquote>
<p>(but I doubt it actually does that)</p>
</blockquote>
<p>intel does something similar afaik and does recommend this pattern for memset</p>



<a name="211078185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/Making%20ParamEnv%20smaller%20makes%20rustc%20slower%20instead%20of%20faster/near/211078185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/Making.20ParamEnv.20smaller.20makes.20rustc.20slower.20instead.20of.20faster.html#211078185">(Sep 24 2020 at 00:35)</a>:</h4>
<p>(at the very least IIRC it saturates the memory bus throughput)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>